package com.dareway.thread;

public class Thread_dirtyRead {
    private static int v = 1;
    public static void main(String[] args) throws InterruptedException {
//        int v = 0;  //lamder表达式中只能操作常量和静态变量
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 1000; i ++ ) v ++;
            System.out.println("线程1完成");
        });
        Thread t2 = new Thread(()->{
            for (int i = 0; i < 1000; i ++ ) v ++;
            System.out.println("线程2完成");
        });
        t1.start();
        t2.start();
        Thread.sleep(1000);
        System.out.println(v);
    }
}
